package com.yihu.cms.service;

import java.io.IOException;

import com.yihu.beans.ResultVO;
import com.yihu.dataService.common.MobileUtil;
import com.yihu.dataService.hessian.mongodb.interfaceService.UserHService;
import com.yihu.dataService.hessian.resource.ResourceMongoDBManager;
import com.yihu.web.bean.SignUp;
import com.yihu.beans.user.User;


public class UserService{
	UserHService userService = null;
	public UserService(){
		try {
			userService= (UserHService)ResourceMongoDBManager
					.getSingleton().getBeans("userServiceHSC");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public ResultVO add(String userJson) {
		// TODO Auto-generated method stub
		return userService.addUser(userJson);
	}

	public ResultVO delete(long id) {
		// TODO Auto-generated method stub
		return userService.deleteUser(id);
	}
	
	public User getUserByOpenid(String openid){
		return userService.getUserByOpenid(openid);
	}

	public String getUserById(long id) {
		String result = "";
		result = userService.getUserById(id);
		return result;
	}

	public ResultVO update(String userJson) {
		return userService.updateUserByid(userJson);
	}
	
	public ResultVO changePassword(String userJson) {
		return userService.changePassword(userJson);
	}
	
	public String login(String userJson) {
		String result = userService.login(userJson);
		return result;
	}

	public String isValidOfUser(long userId) {
		String result = userService.isValidOfUser(userId);
		return result;
	}
	
	
	public String getUsersPaing(String queryJson) {
		// TODO Auto-generated method stub
		String json = userService.getUsersPaging(queryJson);
		System.out.println("cms.json: "+json);
		return json;
	}
	
	public ResultVO logout(long userId) {
		return userService.logout(userId);
	}

	public Object getPriviledgesByUserId(long userId){
		
		return userService.getPriviledgesByUserId(userId);
	}
	
	public Object setAgentLevel(User user){
		
		return userService.setAgentLevel(user);
	}
	
	public Object setUserLevel(User user){
		
		return userService.setUserLevel(user);
	}
	
	public int sendDeliveryMesBySms(SignUp signup)
	{
		return MobileUtil.sendMailMessage(signup);
	}
}
